<template>
  <div class="homeTwo">
    <div class="w">
      <div class="head">
        <h3>热门品牌 <span>国际经典&emsp;品质保证</span></h3>
      </div>
      <div class="box">
        <ul class="left" ref="left">
          <li v-for="item in hotBrand" :key="item.id">
            <img :src="item.picture" alt="" />
          </li>
        </ul>
      </div>
      <!-- 上一页下一页 -->
      <div class="pageTurning">
        <div class="prev" @click="prev" :class="isDisable ? 'disables' : ''">
          <
        </div>
        <div class="next" @click="next" :class="!isDisable ? 'disables' : ''">
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["hotBrand"],
  data() {
    return {
      index: 0,
      // 上下按钮禁用的变量
      isDisable: true,
    };
  },
  methods: {
    prev() {
      this.$refs.left.style.marginLeft = 0 + "px";
      this.isDisable = true;
    },
    next() {
      this.$refs.left.style.marginLeft = -1240 + "px";
      this.isDisable = false;
    },
  },
  mounted() {},
};
</script>

<style lang="scss" scoped>
.disables {
  background-color: gray !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}
.pageTurning {
  width: 60px;
  height: 25px;
  display: flex;
  justify-content: space-between;
  position: absolute;
  right: 20px;
  top: 50px;
  div {
    width: 25px;
    height: 25px;
    background-color: #27ba9b;
    color: white;
    text-align: center;
    line-height: 25px;
    cursor: pointer;
  }
}
.homeTwo {
  width: 100%;
  background-color: #f5f5f5;
  position: relative;
  .w {
    .head {
      width: 100%;
      height: 115px;
      display: flex;
      align-items: center;
      h3 {
        flex: 1;
        font-size: 32px;
        font-weight: 400;
        margin-left: 6px;
        height: 35px;
        line-height: 35px;
        span {
          font-size: 16px;
          color: #999;
          margin-left: 20px;
          vertical-align: middle;
        }
      }
    }
    .box {
      display: flex;
      width: 100%;
      height: 345px;
      overflow: hidden;
      padding-bottom: 40px;
    }
    .left {
      width: 200%;
      padding-bottom: 40px;
      display: flex;
      transition: all 2s;
      li {
        width: 240px;
        height: 305px;
        margin-right: 10px;
        &:nth-child(5n) {
          margin-right: 0;
        }
        img {
          width: 240px;
          height: 100%;
        }
      }
    }
  }
}
</style>
